import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:lcapp/data/lc_video_data_entity.dart';
import 'package:lcapp/widget/asr_cache_image.dart';

class MinVideoItem extends StatefulWidget {
  final LcVideoDataEntity entity;
  final Function clickFun;
  const MinVideoItem({Key? key, required this.entity, required this.clickFun}) : super(key: key);

  @override
  _MinVideoItemState createState() => _MinVideoItemState();
}

class _MinVideoItemState extends State<MinVideoItem> {

  @override
  void didUpdateWidget(covariant MinVideoItem oldWidget) {
    // TODO: implement didUpdateWidget
    super.didUpdateWidget(oldWidget);
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: (){
        if(widget.clickFun!=null){
          widget.clickFun();
        }
      },
      child: Container(
        color: Color.fromRGBO(0, 0, 0, 0.1),
        child: Stack(
          children: [
            Positioned(
              child: ASRCacheImage(
                image: widget.entity.coverPath??'',
                fit: BoxFit.cover,
              ),
              left: 0,right: 0,top: 0,bottom: 0,
            ),
            Positioned(child: Container(
              height: 75.w,
              padding: EdgeInsets.symmetric(horizontal: 20.w),
              decoration: const BoxDecoration(
                gradient: LinearGradient(
                  colors: [Color.fromRGBO(0, 0, 0, 0.1),Colors.transparent],
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter
                )
              ),
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Icon(Icons.play_arrow,color: Colors.white,size: 30.w,),
                  SizedBox(width: 10.w,),
                  Container(
                    child: Text('${widget.entity.playCount}',style: TextStyle(
                        color: Colors.white,
                        fontSize: 24.sp
                    ),),
                  ),
                ],
              ),
            ),bottom: 0,left: 0,right: 0,)
          ],
        ),
      ),
    );
  }
}
